#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;

class Date
{
public:

    void print()
    {
        printf("%d\n", _year);
        printf("%d\n", _month);
        printf("%d\n", _day);
    }

    int GetMonthday(int year, int month)
    {
        int Monthday[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };

        if (month == 2)
        {
            if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
            {
                return Monthday[month] + 1;
            }

            else
            {
                return Monthday[month];
            }


        }

        return Monthday[month];
    }

    int GetDay()
    {
        int nums = 0;

        for (int i = 1; i < _month; i++)
        {
            nums += GetMonthday(_year, i);
        }

        return nums + _day;

    }

    friend istream& operator >>(istream& in, Date& d1);

private:
    int _year;
    int _month;
    int _day;
};

istream& operator >>(istream& in, Date& d1)
{
    in >> d1._year >> d1._month >> d1._day;
    return in;
}
int main()
{
    Date d;
    cin >> d;
    //d.print();
    printf("%d", d.GetDay());
}